package com.shinewind.pojo.entity;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel(description = "用于存放评分的数据模型")
public class Rating implements Serializable {
    private int userId;
    private int modelId;
    private Double rating;

    public static Rating parseRating(String str){
        String[] fields = str.split(",");
        int userId = Integer.parseInt(fields[0]);
        int modelId = Integer.parseInt(fields[1]);
        Double rating = Double.parseDouble(fields[2]);
        return Rating.builder().userId(userId)
                .modelId(modelId).rating(rating)
                .build();
    }
}
